package Model;

import javafx.util.Pair;

import java.awt.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;

public class Map
{
    int tileSize;
    public int width;
    public int length;
    public ArrayList<Point> pivots;
    //public Hashtable<Point,Tile> tiles;
    public Tile[][] tiles;

    /**
     * @param w - width of map
     * @param l - length of map
     * @param tileSize - size of tiles
     */
    public Map(int w, int l, int tileSize){
        width=w;
        length=l;
        this.tileSize = tileSize;
        this.pivots = new ArrayList<Point>();
        //this.tiles = new Hashtable<Point, Tile>();
        this.tiles = new Tile[w][l];
    }

    /**
     * Constructor for a Default Map
     */
    public Map()
    {
        width = 720;
        length = 1280;
        tileSize = 10;
        pivots = new ArrayList<Point>();
        //this.tiles = new Hashtable<Point, Tile>();
        this.tiles = new Tile[width][length];
    }

    /*
    Getters for the map.  Mostly used for mapGen and mapLoading
     */

    public int getPixelWidth(){
        return width;
    }

    public int getPixelLength(){
        return length;
    }

    public int getMaxRow(){
        return (int)Math.ceil(width/tileSize);
    }

    public int getMaxCol(){
        return (int)Math.ceil(length/tileSize);
    }


    public int getTotalPixels(){
        return width*length;
    }

    public int getTotalTiles(){
        return (width*length)/tileSize;
    }

    public int getTileSize(){
        return tileSize;
    }

    public URL[][] initializeTestMap()
    {
        return null;
    }

    public Color getTileColor(int x, int y)
    {
       // Tile t = tiles.get(new Point(x,y));
        Tile t = tiles[x][y];
        return t.getBiome().getColor();
    }

}
